<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body onload=main()>
        <canvas id='webgl' width="400" height='400'>如果你看见我，就请更换别的浏览器查看效果</canvas>
        <script src='lib/webgl-utils.js'></script>
        <script src='lib/webgl-debug.js'></script>
        <script src='lib/cuon-utils.js'></script>
        <script>
            // 顶点着色器
            let VSHADER_SOURCE='attribute vec4 a_Position;void main(){gl_Position=a_Position;gl_PointSize=10.0;}';
            let FSHADER_SOURCE='void main(){gl_FragColor=vec4(1.0,0.0,0.0,1.0);}';

            function main(){
                let canvas=document.getElementById('webgl')
                let gl=getWebGLContext(canvas)
                if(!gl){
                    console.log(没有获取到元素);
                    return false
                }

                if(!initShaders(gl,VSHADER_SOURCE,FSHADER_SOURCE)){
                    console.log(初始化shader失败);
                    return ;
                }
                let a_Position=gl.getAttribLocation(gl.program,'a_Position')
                gl.vertexAttrib4f(a_Position,0.0,0.0,0.0,1.0)
                gl.clearColor(0.0,0.0,0.0,1.0)
                gl.clear(gl.COLOR_BUFFER_BIT)
                gl.drawArrays(gl.POINTS,0,1)
                
            }
        </script>
    
</body>
</html>